package ten;

public class 十八暂停线程 {
    public static void main(String[] args) {
        StateThread st = new StateThread();
        new Thread(st, "CT1").start();
        new Thread(st, "CT2").start();
    }
}


class StateThread implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() + ": " + i);
            try {
//                Thread.sleep(1000);
                Thread.yield();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
